<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="{$Assets}layui/css/layui.css">
    <style type="text/css">
.layui-table-body{
    overflow: hidden;
}
    </style>
</head>
<body>
{include file="public/header" /}

{if condition="$userCheck.ini == 1"} 
<form class="layui-form" action="" style="margin:10px 10px ;float: right;">
    <div class="layui-inline">
      <label class="layui-form-label">筛选</label>
      <div class="layui-input-inline">
        <select name="username">
          <option value="">请选择问题</option>
          {volist name="admin" id="vo" }
                  <option value="{$vo.master}" 
                    {if condition="$username == $vo.master"} selected="" {/if}
                  >{$vo.master}</option>
          {/volist}
        </select>
      </div>
      <button class="layui-btn" lay-submit="" lay-filter="demo1">确认</button>
    </div>
</form>
{/if}

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>{$username}所有订单</legend>
</fieldset>
<div style="width: 98%;margin:0 auto;">
<table class="layui-hide" id="LAY_table_order" lay-filter="order"></table> 
</div>


<script type="text/html" id="type">
  {{# if(d.type=='1'){ }}
        代金卷
  {{# }else if(d.type=='2'){ }}
        礼品卷
  {{# }else if(d.type=='3'){ }}
        积分商品
  {{# } }}
</script>

<script src="{$Assets}layui/layui.js?t=1515376178709"></script>
<script>
layui.use('table', function(){
  var table = layui.table;
  
  //
  table.render({
    elem: '#LAY_table_order'
    ,url: 'myorder?username={$username}'
    ,cols: [[
      {field:'orderid', title:'订单号', width:250, sort: true, fixed: true}
      ,{field:'shoptitle', title: '商品'}
      ,{title: '商品类型',  width:100,toolbar: '#type',align:'center'}
      ,{field:'key', title: '卡密',width:160,align:'center'}
      ,{field:'state_l', title: '状态',  width:80}
      ,{field:'user', title: '会员',  width:160,align:'center'}
      ,{field:'ordertime', title: '下单时间', width:180}
      ,{field:'checktime', width:178, align:'center', title:'操作时间'}
    ]]
    ,id: 'prolist'
    ,page: true
 
  });


  //
  table.on('tool(order)', function(obj){
    var data = obj.data;
    if(obj.event === 'edit'){
      
      layer.open({
        type: 2 //iframe
        ,title: '更新订单'
        ,area: ['400px', '500px']
        ,shade: 0.8

        ,maxmin: true
        ,offset: 'auto'
        ,content: "{:url('order/editorder')}?id="+data.id
        ,zIndex: layer.zIndex //1
        ,success: function(layero){
          layer.setTop(layero); //2
        }
      });


    } else if(obj.event === 'del'){
      layer.confirm('确定删除吗？', function(index){


                  $.ajax({
                        type:"POST",
                        url: "{:url('integral/delshop')}",
                        data:{data:data.id},
                        dataType:"json",

                        success:function(ret_datas){
                            if(ret_datas==1){
                                layer.msg('删除成功!');
                            }else if(ret_datas==99){
                                layer.msg('删除异常');
                            }else{
                                layer.msg(ret_datas);
                            }
                            
                        }
                    });



        obj.del();
        setTimeout(function(){
            location.reload();
        },"1000");
        
      });
    }
  });

  var $ = layui.$, active = {
    reload: function(){
      var demoReload = $('#prolist');
      
      //
      table.reload('testReload', {
        page: {
          curr: 1 // 1 
        }
        ,where: {
          key: {
            id: demoReload.val()
          }
        }
      });
    },
    
   

  };
  
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>

{include file="public/footer"/}
</body>
</html>